package com.hsgene.order.dto.message;

import com.hsgene.common.util.validation.FieldChecker;

import java.io.Serializable;

/**
 * 订单超期检测消息DTO
 *
 * @author wangbing
 * @version 1.0
 * @date 2019/1/23 10:39
 * Copyright: Copyright (c) 2019
 */
public class OrderPostponeMessageDto implements Serializable {

    private static final long serialVersionUID = 7771552636145671619L;
    /**
     * 订单id
     */
    private String orderId;

    /**
     * 订单套餐id
     */
    private String packageId;

    /**
     * 过期时间戳
     */
    private long postponeTimestamp = 0;

    public OrderPostponeMessageDto() {
    }

    public OrderPostponeMessageDto(String orderId, String packageId) {
        this.orderId = orderId;
        this.packageId = packageId;
    }

    public void check() {
        FieldChecker.checkEmpty(orderId, "订单id");
        FieldChecker.checkEmpty(packageId, "套餐id");
    }

    public boolean beyondMaxDelay(final long MAX_DELAY_TIME) {
        return postponeTimestamp - System.currentTimeMillis() > MAX_DELAY_TIME;
    }

    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    public String getPackageId() {
        return packageId;
    }

    public void setPackageId(String packageId) {
        this.packageId = packageId;
    }

    public long getPostponeTimestamp() {
        return postponeTimestamp;
    }

    public void setPostponeTimestamp(long postponeTimestamp) {
        this.postponeTimestamp = postponeTimestamp;
    }
}
